package jjn.round1;

/**
 * @author Jjn
 * @since 2022-08-15 16:00
 */
public class SortingAlgorithm_BubbleSort implements SortAlgorithm {
    
    @Override
    public void sort(int... nums) {
        if (nums == null || nums.length <= 1) {
            return;
        }
        for (int i = 0; i < nums.length; i++) {
            for (int j = i + 1; j < nums.length; j++) {
                if (nums[i] > nums[j]) {
                    int temp = nums[i];
                    nums[i] = nums[j];
                    nums[j] = temp;
                }
            }
        }
    }
    
    @Override
    public String getName() {
        return "Bubble sort";
    }
}
